package cn.edu.scau.cmi.wurihua.Adapter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ObjectAdapter implements SortUtil{
	
	private List<StudentInfo> stuList;
	
	public ObjectAdapter(List<StudentInfo> stuList) {
		this.stuList = stuList;
	}

	@Override
	public List<Integer> sortInt(List<Integer> intList) {
		Collections.sort(intList);
		return intList;	
	}
	
	public List<StudentInfo> sortStudent() {
		List<Integer> intList = new ArrayList<Integer>();
		for(StudentInfo stu:stuList) {
			intList.add(stu.getStuNum());
		}
		intList = sortInt(intList);
		List<StudentInfo> newList = new ArrayList<StudentInfo>();
		for(Integer num:intList) {
			for(StudentInfo info:stuList) {
				if(num==info.getStuNum()) {
					StudentInfo s = new StudentInfo(num,info.getStuName());
					newList.add(s);
					break;
				}
			}
		}
		return newList;
	}
}
